#include "redis/store/redis.h"

int main() {
  rocksdb::Options options;
  options.create_if_missing = true;
  std::string redis_db_path = "./redis_db";
  Redis redis;
  rocksdb::Status s = redis.Open(redis_db_path, options);
  if (!s.ok()) {
    printf("%s\n", s.ToString().c_str());
    return 0;
  }

  {
    std::vector<ScoreMember> score_member;
    score_member.push_back({1.0, "test1_zadd_key"});
    score_member.push_back({4.1034343, "test2_zadd_key"});

    int ret;
    s = redis.ZAdd("test_key", score_member, &ret);
    assert(s.ok());

    s = redis.ZRange("test_key", 0, -1, &score_member);
    assert(s.ok());
  }

  {
    std::vector<ScoreMember> score_member;
    score_member.push_back({1.0, "test_txn_zadd_key"});
    int ret;
    std::shared_ptr<rocksdb::Transaction> txn = redis.Multi();
    s = redis.ZAdd("test_txn_key", score_member, &ret, txn);
    assert(s.ok());
    s = redis.Exec(txn);
    assert(s.ok());
  }
  return 0;
}